package org.example;

import cn.hutool.socket.aio.AioServer;
import cn.hutool.socket.aio.AioSession;
import cn.hutool.socket.aio.IoAction;


import java.nio.ByteBuffer;

public class Socket2 {
    public static void main(String[] args) {
        AioServer aioServer = new AioServer(8899);
        aioServer.setIoAction(new IoAction<ByteBuffer>() {
            @Override
            public void accept(AioSession aioSession) {
                System.out.println("accept");
            }

            @Override
            public void doAction(AioSession aioSession, ByteBuffer byteBuffer) {
                byte[] result=byteBuffer.array();
                System.out.println(new String(result,1,result[0]));

            }

            @Override
            public void failed(Throwable throwable, AioSession aioSession) {

            }
        }).start(true);

    }
}
